﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc.Html;
using System.Web.WebPages.Html;
using Df.Common.Forms;
using System.Web.Mvc;

namespace Df.Web.Mvc
{
    public static class HtmlExtension
    {
        public static MvcHtmlString GenerateHiddenFields<TModel>(this HtmlHelper<TModel> Html, DfBaseElement model)
        {
            var result = string.Empty;
            result += Html.Hidden("Title", model.Title).ToHtmlString();
            result += Html.Hidden("HelpText", model.HelpText).ToHtmlString();
            result += Html.Hidden("ElementId", model.ElementId).ToHtmlString();
            result += Html.Hidden("CurrentMode", model.CurrentMode).ToHtmlString();
            result += Html.Hidden("VisibleMode", model.VisibleMode).ToHtmlString();
            result += Html.Hidden("ModelType", model.GetType()).ToHtmlString();

            result = model.AccessRole.Aggregate(result, (current, accRole) => current + Html.HiddenFor(modelItem => accRole).ToHtmlString());

            return MvcHtmlString.Create(result);
        }
    }
}
